<template>
  <rx-layout>
    <div slot="center" style>
      <rx-fit>
        <div slot="toolheader" foldheader="true" foldbtn="false" border="false">
          <div class="table-operator">
            <rx-button alias="sysErrorLogDelete" :butn-icon="'delete'" :butn-type="'primary'"
                         :show-no-right="true" @click="delByIds(selectedRowKeys)">
                  {{$ti18('rxList.delBtn','删除')}}
            </rx-button>
            <rx-button alias="sysDebugInfoClear" :butnIcon="'retweet'" :butn-type="'danger'" :show-no-right="true" @click="clear">
                {{$ti18('rxList.creanUp','清空')}}
            </rx-button>

          </div>
          <span class="search-btn-box">
                <span class="search-btn" @click="searchshow"><i class="iconfont iconguolv"></i>
                {{$ti18('rxList.leachBtn','过滤')}}</span>
           </span>
        </div>
        <div slot="searchbar" btnalign="right"  v-if="fitSearch" @search="search" @cancel="cancel" @close="close">
          <a-form layout="vertical">
                <a-form-item :label="i18n('form.level','级别')">
                    <a-select v-model="queryParam.Q_LEVEL__I_EQ" :placeholder="i18n('form.level','级别','input')" :options="levelAry" allowClear>
                    </a-select>

                </a-form-item>
                <a-form-item :label="i18n('form.module','模块')">
                    <a-input :placeholder="i18n('form.module','模块','input')" v-model="queryParam.Q_MODULE__S_LK"/>
                </a-form-item>

          </a-form>
        </div>
        <rx-grid
                ref="table"
                :allowRowSelect="true"
                :multiSelect="true"
                :columns="columns"
                :defaultPageSize="10"
                url="/api-system/system/core/sysDebugInfo/query"
                :queryParam="queryParam"
                data-field="result.data"
                :pageSizeOptions="['10','30','40']"
                id-field="id"
                @selectChange="onSelectChange"
        >
            <span slot="level" slot-scope="{ text, record }">
                <a-tag :color="levelMap[text].color">
                    <span>{{ levelMap[text].text }}</span>
                </a-tag>

            </span>
        </rx-grid>
      </rx-fit>
    </div>
  </rx-layout>
</template>

<script>
  import SysDebugInfoApi from '@/api/system/core/sysDebugInfo'
  import SysDebugInfoEdit from './SysDebugInfoEdit'
  import {BaseList,RxFit,RxGrid } from "@lowcode/jpaas-common-lib";
  export default {
    name: 'SysDebugInfoList',
    mixins: [BaseList],
    components: {
      RxFit
    },
    data() {
      return {
        columns: [
          {
            title: this.$ti18('rxList.index','序号'),
            type: 'indexColumn',
            width: 50,
            dataIndex: 'serial',
            scopedSlots: {customRender: 'serial'}
          },
          {title: this.i18n('form.level','级别'), dataIndex: 'level', width: 100,scopedSlots: {customRender: 'level'}},
          {title: this.i18n('form.module','模块'), dataIndex: 'module', width: 100},
          {title: this.i18n('form.content','内容'), dataIndex: 'content', width: 100},
          {title: this.i18n('form.creation','创建时间'), dataIndex: 'createTime', width: 100},

        ],
        component:SysDebugInfoEdit,
        comment:this.i18n('list.comment','系统调试信息'),
        widthHeight:['800px','600px'],
        fitSearch:false,

        levelMap: {
          '1': {color: 'cyan', text: 'debug'},
          '2': {color: 'green', text: 'info'},
          '3': {color: 'orange', text: 'warn'},
          '4': {color: 'red', text: 'error'}
        },
        levelAry:[{value:1,label:"debug"},{value:2,label:"info"},{value:3,label:"warn"},{value:4,label:"error"}]
      }
    },
    methods:{
        i18n(name,text,key){
            return this.$ti18(name,text,"SysDebugInfo",key);
        },
      delById(ids){
        return SysDebugInfoApi.del({ ids: ids.join(',') });
      },
      getListByParams(parameter){
        return SysDebugInfoApi.query(parameter)
      },
      clear(){
          let self_=this;
          this.$confirm({
              title: this.$ti18('rxMsa.actionTips','操作提示'),
              zIndex: 20000,
              content: this.i18n('list.content','确定清除调试日志吗？'),
              okText: this.$ti18('rxForm.ackBtn','确认'),
              cancelText: this.$ti18('rxForm.cancelBtn','取消'),
              onOk() {
                  SysDebugInfoApi.removeByTenantId().then(res=>{
                      self_.refreshGrid()
                  })
              },
              onCancel() {
              }
          })

      }

    }
  }
</script>
<style scoped>

</style>

